package com.example.administrator.capital.home.invite;


import android.app.Fragment;
import android.os.Bundle;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.administrator.capital.R;
import com.example.administrator.capital.adapter.CommentAdapter;
import com.example.administrator.capital.base.BaseBackFragment;
import com.example.administrator.capital.model.TestBean;
import com.example.administrator.capital.presenter.HomePresenter;
import com.example.administrator.capital.presenter.base.IViewRequest;
import com.example.administrator.capital.utils.PreferenceManager;
import com.lzy.okgo.model.Response;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;
import recycle.BaseViewHolder;

/**
 * A simple {@link Fragment} subclass.
 * 邀请详情
 */
public class InviteDetailFragment extends BaseBackFragment {
    @BindView(R.id.recycle_view)
    RecyclerView mRecycleView;
    Unbinder unbinder;
    private CommentAdapter<TestBean> mAdapter;
    private List<TestBean> mTestBeans = new ArrayList<>();
    private HomePresenter mHomePresenter;
    public InviteDetailFragment() {
        // Required empty public constructor
    }
    public static InviteDetailFragment newInstance() {
        Bundle args = new Bundle();
        InviteDetailFragment fragment = new InviteDetailFragment();
        fragment.setArguments(args);
        return fragment;
    }
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_invite_detail, container, false);
        unbinder = ButterKnife.bind(this, view);
        return view;
    }
    @Override
    protected void initView(View view) {
        super.initView(view);
        mHomePresenter = new HomePresenter(null);
        mAdapter = new CommentAdapter<TestBean>(R.layout.investment_item_list,null) {
            @Override
            public void setViewData(BaseViewHolder holder, TestBean item, int position) {
            }
            @Override
            public void setEvent(BaseViewHolder holder, TestBean item, int position) {
            }
        };
        mRecycleView.setLayoutManager(new LinearLayoutManager(getContext()));
        DividerItemDecoration div = new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL);
        div.setDrawable(ContextCompat.getDrawable(getContext(), R.drawable.custom_divider));
        mRecycleView.addItemDecoration(div);
        mRecycleView.setAdapter(mAdapter);
    }
    @Override
    protected void setListener() {
        super.setListener();
    }
    @Override
    protected void setData() {
        super.setData();
        getData();
    }
    private void getData() {
        for (int i = 0; i < 10; i++) {
            mTestBeans.add(new TestBean(0, ""));
        }
        mAdapter.setNewData(mTestBeans);
        mHomePresenter.selective(new IViewRequest<String>() {
            @Override
            public void onFailMsg(String var) {
            }
            @Override
            public void onCode(int code) {
            }
            @Override
            public void onSuccess(Response<String> data) {
            }
            @Override
            public void onFail(Response<String> error) {
            }
        }, PreferenceManager.instance().getUseId());
    }
    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }
}
